import { ColumnProps } from "@/components/Table/type";
import { SchemaProps } from "@/components/Form/type";
const fieldTypeList = [
  { label: "字符", value: "string" },
  { label: "数字", value: "number" },
  { label: "日期", value: "date" },
  { label: "布尔", value: "bool" },
  { label: "文本", value: "text" }
];
export const columns: ColumnProps[] = [
  { type: "index", label: "#", width: 50 },
  { prop: "entityCode", label: "实体编码", search: { el: "input" } },
  { prop: "entityName", label: "实体名称", search: { el: "input" } },
  // { prop: "datasourceName", label: "数据源" },
  { prop: "tableName", label: "数据表" },
  { prop: "action", label: "操作", width: 150, fixed: "right" }
];

export const basicSchemas: SchemaProps[] = [
  {
    field: "entityCode",
    label: "实体编码",
    colProps: {
      span: 12
    },
    disabled: formModel => !!formModel.id,
    required: true
  },
  {
    field: "entityName",
    label: "实体名称",
    colProps: {
      span: 12
    },
    required: true
  },
  {
    field: "datasourceId",
    label: "数据源",
    disabled: formModel => !!formModel.id,
    colProps: {
      span: 12
    },
    required: true
  },
  {
    field: "tableName",
    label: "数据表",
    disabled: formModel => !!formModel.id,
    colProps: {
      span: 12
    },
    required: true
  }
];

export const tableFieldColumns: ColumnProps[] = [
  { type: "index", label: "#", width: 50 },
  { prop: "fieldName", label: "字段名称", el: "input" },
  {
    prop: "fieldCode",
    label: "字段编码",
    render: ({ row }) => {
      if (!!row.pk) {
        return <span>{row.fieldCode}（主键）</span>;
      } else {
        return <span>{row.fieldCode}</span>;
      }
    }
  },
  { prop: "fieldType", label: "字段类型", el: "select", elProps: { options: fieldTypeList } },
  {
    prop: "dictType",
    label: "字典"
  },
  { prop: "checkType", label: "校验", el: "select" },
  {
    prop: "required",
    label: "必填",
    el: "switch",
    width: 100,
    elProps: {
      inlinePrompt: true,
      activeText: "是",
      inactiveText: "否",
      activeValue: 1,
      inactiveValue: 0
    }
  },
  {
    prop: "excel",
    label: "导入导出",
    el: "switch",
    width: 100,
    elProps: {
      inlinePrompt: true,
      activeText: "是",
      inactiveText: "否",
      activeValue: 1,
      inactiveValue: 0
    }
  },
  { prop: "addValue", label: "默认值（新增）", el: "input" },
  { prop: "editValue", label: "默认值（修改）", el: "input" }
];
